home *** CD-ROM | disk | FTP | other *** search
- Path: watnews.watson.ibm.com!ncohen
- From: ncohen@watson.ibm.com (Norman H. Cohen)
- Newsgroups: comp.lang.ada,comp.lang.c
- Subject: Re: C/C++ knocks the crap out of Ada
- Date: 8 Mar 1996 21:11:32 GMT
- Organization: IBM T.J. Watson Research Center
- Distribution: world
- Message-ID: <4hq7q4$qik@watnews1.watson.ibm.com>
- References: <JSA.96Feb16135027@organon.com>
- <4gaa6l$8mk@post.gsfc.nasa.gov> <4gd94r$isu@mack.rt66.com>
- <1996Feb22.005518.13396@leeweyr.sccsi.com>
- <4gvrffINNlqo@anvil.ugrad.cs.ubc.ca>
- <4h4j31$1ga3@watnews1.watson.ibm.com>
- <TANMOY.96Feb29144112@qcd.lanl.gov>
- <4hf485$1mgv@watnews1.watson.ibm.com> <TANMOY.96Mar4155315@qcd.lanl.gov>
- Reply-To: ncohen@watson.ibm.com
- NNTP-Posting-Host: rios8.watson.ibm.com
-
- In article <TANMOY.96Mar4155315@qcd.lanl.gov>, tanmoy@qcd.lanl.gov
- (Tanmoy Bhattacharya) writes:
-
- |> In article <4hf485$1mgv@watnews1.watson.ibm.com>
- |> ncohen@watson.ibm.com (Norman H. Cohen) writes:
- |>
- |> NHC: Famous last words! That's how we all started out! :-)
- |>
- |> Yup. I am replying because there is precisely one mistake in your
- |> argument. (Most of it I actually agree with). But, as I am replying, I
- |> also put forth some arguments.
-
- Yes, in the first stage addicts always deny their addictions. :-)
-
- ...
- |> NHC: The Ada language was originally designed in response to a set of
- |> NHC: requirements promulgated by its intended users. The revision was driven
- |> NHC: by requirements that arose in the programming community, which provided
- |> NHC: plentiful input to a very open process.
- |>
- |> I agree that the language design team got input from the target
- |> community: it however did not have the `field testing' that C got in
- |> its pre-standard phase. That is what I meant.
-
- True of Ada 83, but not of Ada 95.
-
- ...
- |> By the way, doesn't Ada require runtime checks? I thought it did, but
- |> I haven't looked at the language for a long time now: and have never
- |> programmed anything beyond `Hello world' in it. Most of the arguments
- |> in this post are incorrect if this assumption is false.
-
- Yes, Ada certainly does required run-time checks!
-
- ...
- |> NHC: The C
- |> NHC: standard contains to requirement to detect any form of nonconformance at
- |> NHC: compile time. Section 1.7 of the standard states, "A _conforming_hosted_
- |> NHC: _implementation_ shall accept any strictly conforming program. A
- |> NHC: _conforming_freestanding_implementation_ shall accept any strictly
- |> NHC: conforming program in which the use of the features specified in the
- |> NHC: library section (Section 4) is confined to the contents of the standard
- |> NHC: <float.h>, <limits.h>, <stdarg.h>, and <stddef.h>." The converse ("A
- |> NHC: conforming implementation shall reject any program that is not strictly
- |> NHC: conforming.") is noticeably absent. Indeed, the paragraph continues, "A
- |> NHC: conforming implementation may have extensions (including additional
- |> NHC: library functions), provided they do not alter the behavior of any
- |> NHC: strictly conforming program."
- |>
- |> This is the only mistake in your post:
- |>
- |> The standard requires a diagnostic whenever any constraint or syntax
- |> rule is violated. (5.1.1.3). After diagnosing the error, it can do
- |> whatsoever it pleases.
-
- I think ANSI ripped me off! I paid them $60 for a copy of the C
- standard, and the one they sent me only goes up to Section 4. :-)
- (Or perhaps there's a typo in your citation? Please clarify.)
-
- |> In fact, sometimes vendors deliberately want something to invoke
- |> `undefined' behaviour instead of violating a constraint, so that they
- |> can provide an extension that does not need a diagnostic. Some of them
- |> (e.g. $ in a macro name) even get accepted. But, by and large, a
- |> compiler cannot silently compile these category of errors.
-
- I don't understand how this can be reconciled with your previous
- statement.
-
- ...
- |> The Ada community is presumably a group of
- |> people who need to write code which will be reused for a long time,
-
- That's accurate.
-
- |> and probably on stable enough platforms that one does not have to work
- |> around machine/compiler deficiencies.
-
- I don't think the platforms on which Ada programs run are particularly
- more or less stable than those on which, say, C programs run. I don't
- see what you're getting at.
-
- |> It probably is also used by the
- |> community to whom safety is so important that it needs to be enforced
- |> by the language, instead of by programmer's habit and training; and by
- |> coding standards?
-
- Not INSTEAD OF programmer's habit and training, but IN ADDITION TO. It
- is used by a community that considers it irresponsible to have a
- program's correctness rely entirely on the imperfect ability of
- programmers to ferret out error by desk checking and testing.
-
- |> Am I wrong? If I am right, I have little to say about those needs. I
- |> am a scientist by profession: to me it is important to get my results
- |> with the current technology, and not have to wait for future
- |> advances.
-
- I'm not sure what current technology versus future advances has to do
- with your argument. (In particular, I hope you realize that Ada is very
- much a current technology.)
-
- |> Heck, my theory is more likely to be wrong than my
- |> programming;
-
- Either you're a much better programmer than most of us or you have a
- very poor track record as a theoretician.
-
- |> and I would rather write my code in a `manifestly
- |> correct' way and thoroughly check my code (and cross check it);
-
- Typical programming problems can be solved in either a "manifestly
- correct" but slow way, or in a more obscure but faster way. What you
- seem to be saying here is that you are willing to sacrifice performance
- for the sake of greater confidence in the correctness of your prrogram.
- But then you continue:
-
- |> than
- |> write in a language that will check every operation that I do. I
- |> typically code for 3 months human time, and run for 1 year's cpu time:
- |> I do not really care if that 3 months become four, but I can't afford
- |> the 1 year becoming 13 months!
-
- Even if we accept that using C instead of Ada only increases your
- development and debugging time by 33%, and that using Ada instead of C
- increases the execution time of your program by 1/12, I find it hard to
- understand why it is okay for your 16 months to be split 4+12, but not
- 3+13, especially since 3+13 gives you a program in whose correctness you
- can have greater confidence. (But note that even if you used Ada for the
- sake of its compile-time consistency checks, and for its run-time
- checks during your three months of development, but suppressed all the
- run-time checks during your year of production runs, you would still be
- better off than if you had used C, and your program would run just as
- fast.)
-
- |> I have found that C can be used to write small understandable code
- |> with no overhead that I did not count on when I wrote my code.
-
- Ada allows selective or general suppression of run-time checks. For
- every C construct, there is a corresponding Ada construct that has the
- same cost when run with checks suppressed. But many of the checks get
- optimized away (because the compiler deduces that they cannot possibly
- fail), or are not expensive enough to worry about. Many programs,
- particularly scienitific programs, can be sped up significantly by
- suppressing checks in a few small critical inner loops, which can be
- scrutinized especially carefully. The remaining checks contribute very
- little to the overall running time of the program.
-
- --
- Norman H. Cohen ncohen@watson.ibm.com
-